package com.team.arms.public_data.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.team.arms.public_data.domain.ListInformation;
import com.team.arms.public_data.domain.dto.ListInformationDto;
import com.team.arms.public_data.domain.vo.ListInformationVo;
import com.team.arms.service_management_before.domain.vo.StudentStatusRetainVo;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * @Entity com.team.arms.public_data.domain.ListInformation
 */
public interface ListInformationMapper extends BaseMapper<ListInformation> {

    int insertAll(ListInformation listInformation);

    @Select("SELECT l.list_information_id,l.conscription_year,l.conscription_batches,l.manifest_contents,s.soldier_info_name\n" +
            "    FROM g_list_information AS l,g_soldier_information AS s\n" +
            "    WHERE l.soldier_info_id=s.soldier_info_id")
    List<ListInformationVo> selectList();

    @Select("SELECT l.list_information_id,l.conscription_year,l.conscription_batches,l.manifest_contents,s.soldier_info_name\n" +
            "from g_list_information AS l,g_soldier_information AS s\n"+
            "where l.soldier_info_id=s.soldier_info_id\n" +
            "and l.list_information_id = #{listInformationId,jdbcType=VARCHAR}")
    ListInformationVo selectAllByListInformationId(@Param("listInformationId") String listInformationId);

    @Select("<script>SELECT l.list_information_id,l.conscription_year,l.conscription_batches,l.manifest_contents,s.soldier_info_name\n" +
            "from g_list_information AS l,g_soldier_information AS s\n"+
            "where l.soldier_info_id=s.soldier_info_id\n" +
            "<if test=\"conscriptionYear != null and conscriptionYear != ''\">\n" +
            "        and l.conscription_year = #{conscriptionYear}\n" +
            "    </if><if test=\"conscriptionBatches != null and conscriptionBatches != ''\">\n" +
            "        and l.conscription_batches = #{conscriptionBatches}\n" +
            "    </if><if test=\"soldierInfoName != null and soldierInfoName != ''\">\n" +
            "        and s.soldier_info_name like CONCAT('%',#{soldierInfoName},'%')\n" +
            "    </if></script>")
    List<ListInformationVo> selectListInformation(ListInformationDto listInformationDto);

    @Select("SELECT l.list_information_id,l.conscription_year,l.conscription_batches,l.manifest_contents,s.soldier_info_name\n" +
            "from g_list_information AS l,g_soldier_information AS s\n"+
            "where l.soldier_info_id=s.soldier_info_id\n" +
            "AND ${field} like \"%${content}%\"")
    List<ListInformationVo> selectByFiled(@Param("field") String field, @Param("content") String content);



}




